Ccay.Module.define("Ccay.example.ui.chart.jqplot",function(page,$S){
	page.ready=function(){
		/*
		 * 初始化
		 */
		$("#barDemo").ccayTab({
			fnAfterSelectItem: function(tabId){
				if(tabId == 'chart' && !$S("#chart").hasClass("jqplot-target")){
					renderPieChart();
				}else if(tabId == 'chart1' && !$S("#chart1").hasClass("jqplot-target")){
					renderPieChart2();
				}
			}
		});
	}
	/*
	 * 饼图  示例一
	 */
	var renderPieChart = function(){
		var data = [['重工业', 30], ['轻工业', 40],['零售', 10],['其他', 20]];
		$("#chart").chart2({
			data: [data],
			skin: {
				seriesDefaults: {
	             renderer: jQuery.jqplot.PieRenderer, 
	             rendererOptions: {
	               showDataLabels: true
	             }
	           }, 
	           legend: { show:true, location: 'e' }
			},
    	    click: function (ev, seriesIndex, pointIndex, data) {
				Ccay.UI.topBox("The seriesIndex is {0}, pointIndex is {1}, x is {2}, y is {3}. 注册 click 事件并显示明细数据或者Chart可以达到钻取的效果。".formatValue( seriesIndex, pointIndex , data[0], data[1]));
            }
		});
	}
	/*
	 * 饼图  示例二
	 */
	var renderPieChart2 = function(){
		var s1 = [['Sony',7], ['Samsumg',13.3], ['LG',14.7], ['Vizio',5.2], ['Insignia', 1.2]];
   		$("#chart1").chart2({
   			data: [s1],
   			skin: {
   				grid: {
   	   	            drawBorder: false, 
   	   	            drawGridlines: false,
   	   	            background: '#ffffff',
   	   	            shadow:false
   	   	        },
   	   	        seriesDefaults:{
   	   	            renderer:$.jqplot.PieRenderer,
   	   	            rendererOptions: {
   	   	                showDataLabels: true
   	   	            }
   	   	        },
   	   	        legend: {
   	   	            show: true,
   	   	            rendererOptions: {
   	   	                numberRows: 1
   	   	            },
   	   	            location: 's'
   	   	        }
   			}
   		});
	}
})